#!/usr/bin/env python

# this script takes a parameter which is the ABSOLUTE PATH to the site

import os, sys

if len ( sys.argv ) < 2:
	print "Missing liwe.yaml path!"
	sys.exit ( 1 )

site_path = sys.argv [ 1 ]
liwe_yaml_path = os.path.join ( site_path, 'cfg' )

if not os.path.exists ( os.path.join ( liwe_yaml_path, 'liwe.yaml' ) ):
	print "liwe.yaml not found in '%s'" % liwe_yaml_path
	sys.exit ( 1 )

from liwe import liwe
from liwe.fake import FakePyHP

from newsletter_class import Newsletter

l = liwe ( FakePyHP (), home_dir = liwe_yaml_path )

n = Newsletter ( l )
#n.base_url = sys.argv [ 2 ]
n.cron ( os.path.join ( site_path, 'web' ) )
